package com.chuanyekeji.aokai.Controller;

import com.chuanyekeji.aokai.Entity.About;
import com.chuanyekeji.aokai.Mapper.AboutMapper;
import com.chuanyekeji.aokai.Util.ReturnData;
import com.google.gson.Gson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@CrossOrigin(origins = "*",maxAge = 3600)
@RestController
public class AboutComtroller {

    @Autowired
    AboutMapper aboutMapper;

    /**
     * 获取关于信息
     * @return
     */
    @RequestMapping("getAboutInfo")
    String getAboutInfo() {
        Gson gson = new Gson();
        About about = aboutMapper.getAboutInfo();
        return ReturnData.success("success",gson.toJson(about));
    }

    /**
     * 修改关于信息
     * @param about
     * @return
     */
    @RequestMapping("changeAboutInfo")
    String changeAboutInfo(About about) {
        About a = aboutMapper.getAboutInfo();
        about.setId(a.getId());
        aboutMapper.updateByPrimaryKeySelective(about);
        return "修改成功";
    }
}
